//头部
app.directive('headbar',function(){
	return{
		restrict:'E',
		templateUrl:'template/head.html',
		replace:true,
		link:function(scope){
            scope.showMe=false;
            scope.toggle=function(){
            	scope.showMe=!scope.showMe;
		    };

            //placeholder兼容ie9
            debugPlaceholer("请输入原密码",'#oldPassword');
            debugPlaceholer("请输入新密码",'#newPassword');
            debugPlaceholer("请再输入新密码",'#confirmPassword');


		    function isPlaceholder(){
		       var input=document.createElement('input');
		       return 'placeholder' in input;
		    }

		    function debugPlaceholer(str,id){
            
			    if(!isPlaceholder()){
			        var label=document.createElement('label');
			        label.style.position='absolute';
			        label.style.left=20+'px';
			        label.style.top=19+'px';
			        label.innerHTML=str;
			        label.style.fontWeight='normal';
			        label.style.color='#ccc'
			        var input=document.querySelector(id);
			        var oDiv=input.parentNode
			        oDiv.appendChild(label);

			        label.onclick=function(){
			           label.style.display='none';
			           input.focus();
			        }
			        input.onfocus=function(){
			            label.style.display='none';
			        }
			        input.onblur=function(){
			            if(input.value==''){
			                label.style.display='block';
			            }
			        }
			    }
			}


	    }
	}
});


//左侧部分
app.directive('leftbar',function(){
	return{
		restrict:'E',
		templateUrl:'template/leftbar.html',
		replace:true,
		link:function(){
			$('.site-menu-item a').click(function(){
				$('.site-menu-item a').css('color','rgba(163,175,183,.9)');
				$(this).css('color','#fff');
			})
		}
	}
})

//左侧部分
app.directive('page',function(){
	return{
		restrict:'E',
		templateUrl:'template/page.html',
		replace:true,
		link:function(){
			
		}
	}
})

//主页跳转
app.directive('mainpage',function(){
	return{
		restrict:'E',
		template:"<a ng-click='mainGo()'>后台首页</a>",
		replace:true
	}
})

/*app.directive('accordion', function($compile) {
  return {
    restrict: 'EA',  
    replace: true,
    scope: {
      expander: '='
    },
    template: "<li" 
    		+ " ng-class='{\"active\":isSelect{{expander.menuId}}}'" 
    		+ " ng-click='selectNav(expander.menuId)'" + 
    		"><a href=\"#\">{{expander.menuName}}</a></li>",
    link: function(scope,elm) { 
    if(scope.child){
    	
    }
         
    }
  };
});*/

/*app.directive('accordion', function($compile) {
	  return {
	    restrict: 'EA',  
	    replace: true,
	    scope: {
	      expander: '=',
	      child: '='
	    },
	    template: "<ul  > <li>{{expander.menuName}}</li></ul>",
	    link: function(scope,elm) { 
	    if(scope.child){
	    var html=$compile("<accordion   expander='expander' child='expander.child' ng-repeat='expander in child'></accordion>")(scope);
	        elm.append(html)
	    }
	         
	    }
	  };
	});*/